package pl.edu.pw.polygen.modeler.client.graph;

import java.util.ArrayList;
import java.util.List;

/**
 * @author borysfan
 * @13-12-2011 @13:04:16
 * Class implements Observer Pattern.
 */
public class BaseModel implements IPropertyChangeSubject{
	private List<IPropertyChangeListener> listeners;
	private int boundary;

	public BaseModel(){
		listeners=new ArrayList<IPropertyChangeListener>();
	}
	
	@Override
	public void addPropertyChangeListener(IPropertyChangeListener listener) {
		if(!listeners.contains(listener)){
			listeners.add(listener);
		}
	}

	@Override
	public void removePropertyChangeListener(IPropertyChangeListener listener) {
		if(listeners.contains(listener)){
			listeners.remove(listener);
		}
	}
	

	@Override
	public List<IPropertyChangeListener> getPropertyChangeListener() {
		return listeners;
	}

	@Override
	public void notifyObservers() {
		for(IPropertyChangeListener listener : listeners){
			listener.notifyChanges();
		}
	}

	public int getBoundary() {
		return boundary;
	}

	public void setBoundary(int boundary) {
		this.boundary = boundary;
	}
	
}
